package redis

import "time"

func CacheSendSms(Mobile, Code, Source string) error {
	key := "send_code" + Source + "mobile_" + Mobile
	return ClientRedis.Set(key, Code, time.Minute*3).Err()
}

func GetSendSms(Mobile, Source string) string {
	key := "send_code" + Source + "mobile_" + Mobile
	return ClientRedis.Get(key).Val()
}
func SendSmsLimit(Mobile string) bool {
	key := "send_count" + Mobile
	if ClientRedis.Get(key).Val() == "" {
		ClientRedis.Set(key, "1", time.Minute*2)
	}
	if ClientRedis.Get(key).Val() > "3" {
		ClientRedis.Incr(key)
		return true
	}
	return false
}
func DelSend(Mobile, Source string) error {
	key := Source + Mobile
	return ClientRedis.Del(key).Err()
}
